<form id="edit-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
    <input id="c-config_id" type="hidden" value="{$row.id}">
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('绑定应用')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-app_id" data-rule="required" min="0" data-source="app/index" class="form-control selectpage" data-primary-key="app_id"  data-field="app_name" data-search-field="app_name" name="row[app_id]" type="text" value="{$row.app_id}">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('选择分组')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-config_type" data-rule="required" data-source="appconfigtype/index" class="form-control selectpage" data-primary-key="id"  data-field="name" data-search-field="name" name="row[config_type]" type="text" value="{$row.config_type|htmlentities}">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('变量名称')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-config_name" readonly data-rule="required" class="form-control" name="row[config_name]" type="text"
                   value="{$row.config_name|htmlentities}">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('中文名称')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-config_desc" data-rule="required" class="form-control" name="row[config_desc]" type="text"
                   value="{$row.config_desc|htmlentities}">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('配置值类型')}:</label>
        <div class="col-xs-12 col-sm-8">
            <select id="c-config_value_type" name="row[config_value_type]" class="form-control">
                {foreach name="config_value_type_list" item="value" }
                <option {if condition="$key==$row.config_value_type"}selected="selected"{/if} value="{$key}">{$value}</option>
                {/foreach}
            </select>
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('设置配置值')}:</label>
        <div class="col-xs-12 col-sm-8" id="c-config_value_dom">
            {switch $row.config_value_type}
            {case string}
            <input id="{$inputId}"  type="text" name="{$inputName}" value="{$row.config_value|htmlentities}"
                   class="form-control" data-rule="required" data-tip="{$row.config_tip}"/>
            {/case}
            {case password}
            <input id="{$inputId}"  type="password" name="{$inputName}" value="{$row.config_value|htmlentities}"
                   class="form-control" data-rule="required" data-tip="{$row.config_tip}"/>
            {/case}
            {case text}
            <textarea id="{$inputId}"  name="{$inputName}" class="form-control" data-rule="required" rows="5" data-tip="{$row.config_tip}">{$row.config_value|htmlentities}</textarea>
            {/case}
            {case editor}
            <textarea id="{$inputId}"  name="{$inputName}"  class="form-control editor" data-rule="required" rows="5" data-tip="{$row.config_tip}">{$row.config_value|htmlentities}</textarea>
            {/case}
            {case list}
            <dl class="fieldlist" data-name="config_value" data-template="config_value_tpl">
                <dd>
                    <a href="javascript:;" class="btn btn-sm btn-success btn-append"><i class="fa fa-plus"></i> 追加</a>
                </dd>
                <textarea name="config_value" class="form-control hide" cols="30"
                          rows="5">{$row.config_value|htmlentities}</textarea>
            </dl>
            <script type="text/html" id="config_value_tpl">
                <dd class="form-inline">
                    <input style="width: 418px;" type="text" name="row[<%=name%>][<%=index%>]"
                           class="form-control" value="<%=row%>" size="100">
                    <span class="btn btn-sm btn-danger btn-remove"><i class="fa fa-times"></i></span> <span
                        class="btn btn-sm btn-primary btn-dragsort"><i class="fa fa-arrows"></i></span>
                </dd>
            </script>
            {/case}
            {case map}
            <dl class="fieldlist" data-name="{$inputName}">
                <dd>
                    <ins>键名</ins>
                    <ins>键值</ins>
                </dd>
                <dd>
                    <a href="javascript:;" class="btn btn-sm btn-success btn-append"><i class="fa fa-plus"></i> 追加</a>
                </dd>
                <textarea name="{$inputName}" class="form-control hide" cols="30" rows="5">{$row.config_value|htmlentities}</textarea>
            </dl>
            {/case}
            {case date}
            <input id="{$inputId}"  type="text" name="{$inputName}" value="{$row.config_value|htmlentities}" class="form-control datetimepicker" data-date-format="YYYY-MM-DD" data-tip="{$row.config_tip}" data-rule="required"/>
            {/case}
            {case time}
            <input id="{$inputId}"  type="text" name="{$inputName}" value="{$row.config_value|htmlentities}" class="form-control datetimepicker" data-date-format="HH:mm:ss" data-tip="{$row.config_tip}" data-rule="required"/>
            {/case}
            {case datetime}
            <input id="{$inputId}"  type="text" name="{$inputName}" value="{$row.config_value|htmlentities}" class="form-control datetimepicker" data-date-format="YYYY-MM-DD HH:mm:ss" data-tip="{$row.config_tip}" data-rule="required"/>
            {/case}
            {case datetime-range}
            <input id="{$inputId}"  type="text" name="{$inputName}" value="{$row.config_value|htmlentities}" class="form-control datetimerange" data-tip="{$row.config_tip}" data-rule="required"/>
            {/case}
            {case number}
            <input id="{$inputId}"  type="number" name="{$inputName}" value="{$row.config_value|htmlentities}" class="form-control" data-tip="{$row.config_tip}" data-rule="required"/>
            {/case}
            {case switch}
            <input id="{$inputId}"  name="{$inputName}" data-tip="{$row.config_tip}" type="hidden" value="{:$row.config_value ? 1:0}">
            <a href="javascript:;" data-toggle="switcher" class="btn-switcher" data-input-id="{$inputId}"  data-yes="1"  data-no="0">
                <i class="fa fa-toggle-on text-success {if !$row.config_value}fa-flip-horizontal text-gray{/if} fa-2x"></i>
            </a>
            {/case}
            {/switch}
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('配置权限')}:</label>
        <div class="col-xs-12 col-sm-8">
            <div class="col-xs-12 col-sm-8">
                {:build_radios('row[config_purview]', ['10'=>__('私有'), '20'=>__('公开')],$row.config_purview)}
            </div>
        </div>
    </div>

    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('配置备注信息')}:</label>
        <div class="col-xs-12 col-sm-8">
            <textarea id="c-remark" data-rule="required" class="form-control" name="row[remark]">{$row.remark|htmlentities}</textarea>
        </div>
    </div>

    <div class="form-group layer-footer">
        <label class="control-label col-xs-12 col-sm-2"></label>
        <div class="col-xs-12 col-sm-8">
            <button type="submit" class="btn btn-primary btn-embossed disabled">{:__('OK')}</button>
            <button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
        </div>
    </div>
</form>
